package pl.enigmatic;

import java.util.Iterator;
import java.util.List;


public abstract class SimpleIterator<T> implements Iterator<T> {

	private final List<T> list;

	public SimpleIterator(final List<T> list) {
		this.list = list;
	}

	private int next = 0;
	private T current = null;

	@Override
	public boolean hasNext() {
		return next < list.size();
	}

	@Override
	public T next() {
		return current = list.get(next++);
	}

	@Override
	public void remove() {
		remove(current);
		next--;
		current = null;
	}

	protected abstract void remove(T t);

}
